package com.aaa.controller;


import com.aaa.entity.ZcglPublic;
import com.aaa.entity.ZcglPubliclands;
import com.aaa.service.ZcglPubliclandsService;
import com.aaa.util.Result;
import com.baomidou.mybatisplus.extension.api.ApiController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * (ZcglPubliclands)表控制层
 *
 * @author makejava
 * @since 2021-01-19 16:52:00
 */
@RestController
@RequestMapping("/public")
public class ZcglPubliclandsController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private ZcglPubliclandsService service;


    @RequestMapping("/aaa")
    public Result listAll(){

        return service.listAll();
    }

    /**
     * create by: Student洋
     * description: 分页查询  count表示第几页  size表示一页几条数据 （后期加上模糊查询）
     */
    @RequestMapping("/page")
    public Result listPage(long count,long size) {
        count-=1;

        List<ZcglPubliclands> zcglPubliclandsPage = service.listPage(count,size);
        return new Result(1002,"成功",zcglPubliclandsPage);
    }

    /**
     * create by: Student洋
     * description: 根据资产编号进行单条记录的详细查询
     */
    @RequestMapping("/one")
    public Result Select(String assetNumber) {
         List<ZcglPublic> list = service.selectOne(assetNumber);
        return new Result(1005,"数据详情 ",list) ;
    }
    /**
     * create by: Student洋
     * description: 逻辑删除
     */

    @RequestMapping("/del")
    public Result delete(String assetNumber) {
         boolean del = service.delete(assetNumber);
         if (del){
             return new Result(1005,"删除成功 ",null) ;
         }
        return new Result(1005,"删除失败 ",null) ;
    }
    /**
     * create by: Student洋
     * description: 添加操作 双表，同时往两个表里添加数据
     */
    @RequestMapping("/add")
    public Result add(@RequestBody ZcglPublic add){
        int a = service.addPublic(add);
        int b = service.addHouse(add);
        if (a != 0 & b !=0 ){
            return new Result(1023,"添加成功",null);
        }
        return new Result(1023,"添加失败",null);
    }




}